
#ifndef __TIMER_H
#define __TIMER_H

#include "gd32f30x.h"
#include <stdbool.h>


#define CONFIG_MCU_FREQUENCY  120
#define TIMER_RCU_TIMERx RCU_TIMER1
#define TIMER_TIMERx TIMER1
#define TIMER_TIMERx_IRQn TIMER1_IRQn
#define TIMER_TIMERx_IRQHandler TIMER1_IRQHandler

typedef union
{
    struct
    {
				uint32_t	timer_ms;
        uint32_t	timer_s;
        uint32_t	timer_100us;
				uint32_t	temp_ms;
    } Info;
    uint32_t Byte[4];
} TimerData_union;

typedef struct
{
    uint32_t (*GetCurrentTime_s)(void);
		uint32_t (*GetCurrentTime_ms)(void);
		bool (*IsTimeOut_s)(uint32_t *tick, uint32_t delay_time);
		bool (*IsTimeOut_ms)(uint32_t *tick, uint32_t delay_time);
} TimerControl_struct;

typedef struct
{
		TimerData_union Data;
		TimerControl_struct Control;
} Timer_struct;

void vtimerInit(void);

uint32_t vtimerGetCurrentTime_s(void);
uint32_t vtimerGetCurrentTime_ms(void);

bool vtimerIsTimeOut_s(uint32_t *tick, uint32_t delay_time);
bool vtimerIsTimeOut_ms(uint32_t *tick, uint32_t delay_time);

#endif

